//
//  FLLVideoViewController.m
//  FLLGodOfCooking
//
//  Created by LL.F on 16/9/21.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "FLLVideoViewController.h"
# import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface FLLVideoViewController ()
@property (nonatomic, strong) AVPlayer *videoPlayer;
@end

@implementation FLLVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
//构造 URL 对象:
NSURL *url = [NSURL URLWithString:_linkString];
//构造 AVPlayerItem 对象:
AVPlayerItem *item = [[AVPlayerItem alloc]initWithURL:url];
//初始化 videoPlayer:
self.videoPlayer = [[AVPlayer alloc]initWithPlayerItem:item];
//到这一步没有画面,需要创建 AVPlayerLayer 对象:
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:_videoPlayer];
playerLayer.frame = self.view.frame;
playerLayer.videoGravity = AVLayerVideoGravityResizeAspect;//让视频根据frame 居中
[self.view.layer addSublayer:playerLayer];
//设置横向全屏:
playerLayer.bounds = CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width);
//让视图旋转90度:(把锁屏按钮点亮)
playerLayer.transform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1);
[self.videoPlayer play];



}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
